
package guoan.web.weixin;

import guoan.service.weixin.WechatService;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @ClassName: OauthContrller
 * @Description: 通过认证界面进行验证跳转
 * @author Administrator
 * @date 2015年4月21日 下午4:36:50
 * 
 */
@Controller
@RequestMapping("/listMsg")
@Scope("prototype")
public class LisMsgContrller {
    protected final Logger log = LoggerFactory.getLogger(getClass());
    @Autowired
    private WechatService wechatService;

    /**
     * 投票首页转发
     * 
     * @throws IOException
     */
    @RequestMapping(value = "{ta}", method = RequestMethod.POST)
    public void post(@PathVariable("ta") String ta, HttpServletRequest req,
            HttpServletResponse resp) throws IOException{
        wechatService.setRequest(req);
        String result = wechatService.execute();
        resp.getOutputStream().write(result.getBytes());
    }

    /**
     * 投票首页转发
     * 
     * @throws IOException
     */
    @RequestMapping(value = "{ta}", method = RequestMethod.GET)
    public void get(@PathVariable("ta") String ta, HttpServletRequest req,
            HttpServletResponse resp) throws IOException{
        wechatService.setRequest(req);
        String result = wechatService.execute();
        resp.getOutputStream().write(result.getBytes());
    }

}
